//
//  HTTPClient.h
//  DebugDemo
//
//  Created by XFB on 2018/11/22.
//  Copyright © 2018年 ZhouCheng. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/// 请求成功Bklock
typedef void(^HTTPRequestSuccessBlock)(id responseObject);
/// 请求失败Block
typedef void(^HTTPRequestFailureBlock)(NSError *error);

@interface HTTPClient : NSObject

/// 取消所有HTTP请求
+ (void)cancelAllRequest;


/**
 GET请求

 @param urlString 请求URL
 @param parameters 请求参数
 @param success 成功回调
 @param failure 失败回调
 @return <#return value description#>
 */
+ (NSURLSessionTask *)getURL:(NSString *)urlString
                   parameter:(id)parameters
                     success:(HTTPRequestSuccessBlock)success
                     failure:(HTTPRequestFailureBlock)failure;

/**
 POST请求

 @param urlString 请求URL
 @param parameters 请求参数
 @param success 成功回调
 @param failure 失败回调
 @return <#return value description#>
 */
+ (NSURLSessionTask *)postURL:(NSString *)urlString
                    parameter:(id)parameters
                      success:(HTTPRequestSuccessBlock)success
                      failure:(HTTPRequestFailureBlock)failure;

@end

NS_ASSUME_NONNULL_END
